<?php
	$profiler = Zend_Db_Table::getDefaultAdapter()->getProfiler();
	$totalTime    = $profiler->getTotalElapsedSecs();
	$queryCount   = $profiler->getTotalNumQueries();
	$longestTime  = 0;
	$longestQuery = null;
?>
<?php if(!empty($queryCount)):?>
<div >
<table style="font-size:80%;">
	
		<?php 
			$i = 1;
			$j = 1;
		?>
		<?php foreach ($profiler->getQueryProfiles() as $query):?>
			<?php
				if ($query->getElapsedSecs() > $longestTime) {
					$longestTime  = $query->getElapsedSecs();
					$longestQuery = $query->getQuery();
					$j = $i;
				}
				$i++;
			?>			
		<?php endforeach;?>		
		<tr>
			<th class="top" width="5%" scope="row" style="height:2em;">No.</th>
			<th class="top" width="80%" scope="row" style="height:2em;">Sql</th>
			<th class="top" width="15%" scope="row" style="height:2em;">Time(s)</th>
		</tr>
		<?php 
			$i = 1;
		?>
		<?php foreach ($profiler->getQueryProfiles() as $query):?>
			<tr>
				<td scope="row" style="height:1.5em;">
						
						<?php if($i == $j):?>
							<font color="blue"><?php echo $i;?></font>
						<?php else:?>
							<?php echo $i;?>
						<?php endif;?>
					</td>
				<td style="height:1.5em;">
						<?php if($i == $j):?>
							<font color="blue"><?php echo $query->getQuery();?></font>
						<?php else:?>
							<?php echo $query->getQuery();?>
						<?php endif;?>
					</td>
				<td style="height:1.5em;">
					<?php if($i == $j):?>
						<font color="blue"><?php echo substr($query->getElapsedSecs(),0,9);?></font>
					<?php else:?>
						<?php echo substr($query->getElapsedSecs(),0,9);?>
					<?php endif;?>
				</td>
				<?php
					$i++;
				?>			
			</tr>
		<?php endforeach;?>	
		<tr>
			<td colspan="2" style="height:1.5em;"/>			
			<td style="height:1.5em;">
				<font color=red> <?php echo substr($totalTime,0,9); ?>(T)</font>
			</td>					
		</tr>		
	
</table>
</div>
<?php endif;?>	